package vn.training.view.bean;

import javax.faces.event.ActionEvent;

import oracle.adf.view.rich.render.ClientEvent;

import oracle.ui.pattern.dynamicShell.TabContext;

import vn.training.view.HrConstant;
import vn.training.view.LocaleSettingViewHandler;
import vn.training.view.util.JSFUtils;

public class Launcher extends BaseFlowBean {
    
    public void launchDefaultActivity(ClientEvent clientEvent) {
        //String tabTitle = String.valueOf(LocaleSettingViewHandler.evaluateEL("#{vcBundle.Departments}"));
        launchDefaultTab(String.valueOf(LocaleSettingViewHandler.evaluateEL("#{vcBundle.Departments}")), HrConstant.DEPARTMENT_TASK_FLOW, false);
        launchDefaultTab(String.valueOf(LocaleSettingViewHandler.evaluateEL("#{vcBundle.Employees}")), HrConstant.EMPLOYEE_TASK_FLOW, false);
        launchDefaultTab(String.valueOf(LocaleSettingViewHandler.evaluateEL("#{vcBundle.Jobs}")), HrConstant.JOB_TASK_FLOW, false);
        
        TabContext.getCurrentInstance().setSelectedTabIndex(0);
    }
    
    public void launchDefaultTab(String tabTitle, String taskflowId, boolean newTab) {
        launchActivity(tabTitle, taskflowId, false);
        getCurrentTab().setTitle(tabTitle);
    }
    
    /*public void openDepartmentsTab(ActionEvent actionEvent) {
        try {
            TabContext.getCurrentInstance().setTabsRendered(true);
            TabContext.getCurrentInstance().addTab("Departments", HrConstant.DEPARTMENT_TASK_FLOW);

        } catch(TabContext.TabOverflowException toe) {
            toe.handleDefault();
        }
    }*/
    
    public void closeCurrentTab(ActionEvent actionEvent) {
        TabContext.getCurrentInstance().removeCurrentTab();
    }
}
